package com.heima.article.listener;

import com.heima.article.service.ApArticleConfigService;
import com.heima.common.constants.WemediaConstants;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
 * @ClassName ArticleCommentListener
 * @Description
 * @Author yangjiangping
 * @Date 2023/6/29 9:50
 * @Version 1.0
 **/
@Component
@Slf4j
public class ArticleCommentListener {

    @Autowired
    private ApArticleConfigService apArticleConfigService;

    /**
     * 修改评论状态消费者
     * @Description
     * @Author YangJiangPing
     * @Date 10:08 2023/6/29
     * @Param [message]
     * @return void
     **/
    @KafkaListener(topics = WemediaConstants.COMMENT_UPDATE_IS_COMMENT_TOPIC)
    public void updateComment(String message){
        if (StringUtils.isBlank(message)){
            throw new NullPointerException("修改评论状态消费端发生错误:原因是message为:"+message);
        }
        apArticleConfigService.updateComment(message);
    }
}

